package com.zhiyou100.crowd.Controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhiyou100.crowd.Iservice.CrowdIservice;
import com.zhiyou100.crowd.Iservice.ProtypeuserIservice;
import com.zhiyou100.crowd.pojo.ViewProTyUs;
import com.zhiyou100.crowd.pojo.ViewProjectType;


@Controller
@RequestMapping("crowd")
public class CrowdController {
	@Resource(name="crowdIservice")
	private CrowdIservice crowdIservice;
	@Resource(name="protypeuserIservice")
	private ProtypeuserIservice protypeuserIservice;
	
	private HttpServletRequest request;

	@ModelAttribute
	public void getrequest(HttpServletRequest request) {
		this.request=request;
	}
	
	@RequestMapping("show.do")
	public String show(@RequestParam(defaultValue="1",required=true)Integer page,ViewProjectType viewProjectType) {
		PageHelper.startPage(page,4);
		List<ViewProjectType> list=crowdIservice.select(viewProjectType);
		PageInfo<ViewProjectType> pageInfo=new PageInfo<ViewProjectType>(list);
		request.setAttribute("pagesp",pageInfo);
		request.getSession().setAttribute("crowd_name", list);
		return "gyzc-list";
	}
	
	@RequestMapping("product.do")
	public String showu(ViewProTyUs viewProTyUs) {
		ViewProTyUs list=protypeuserIservice.select(viewProTyUs);
		request.setAttribute("pro_user", list);
		return "product-detail";
	}
	
}
